var express = require('express');
var router = express.Router();

/* GET users listing. */
router.get('/', async function(req, res, next) {
  
const Dysmsapi20170525 = require('@alicloud/dysmsapi20170525');
const OpenApi = require('@alicloud/openapi-client');
const config = new OpenApi.Config({
  // 必填，请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
  accessKeyId: 'LTAI5tNaJgC99iUqPGHwAEzn',
  // 必填，请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
  accessKeySecret: "qqTthEdqusULCFfSJtyTuTpTVPdL2g",
});
// Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
config.endpoint = `dysmsapi.aliyuncs.com`;
const client = new Dysmsapi20170525.default(config);
const sendSmsRequest = new Dysmsapi20170525.SendSmsRequest({
  signName: '阿里云短信测试',
  templateCode: 'SMS_154950909',
  phoneNumbers: '18522374667',
  templateParam: '{"code":"1234"}',
});

const result = await client.sendSmsWithOptions(sendSmsRequest, {}, (err, resp) => {
  if (err) {
    console.error(err);
  } else {
    console.log(resp);
  }
});
console.log(result)
  res.send('respond with a resource');
});

module.exports = router;
